<?php
class App_Module_Admin_Component_Tags_Ctrl_Http_Ajax extends Mozg_Controller_Instance
{
	const MAX_TAGS_IN_LIST = 20;
    public function listPrAction()
    {
    	$area = trim(urldecode(Mozg::Request('http')->getQuery('area')));
    	$tag = trim(urldecode(Mozg::Request('http')->getQuery('tag')));

    	$preparedData = array();

    	if (Mozg::Lib('str')->Len($tag) > 1)
    	{
	    	$tags = Mozg_Mapper::Get('Tags')->GetList(array('area' => $area, 'tag' => $tag), new Mozg_Paginator(1, self::MAX_TAGS_IN_LIST));
			foreach ($tags as $tag)
	    	{
				$preparedData[] = $tag['tag'];
	    	}
    	}

        Mozg::Response('http')->SetBody(Mozg::Lib('Json')->Encode($preparedData));
        Mozg::Layout('admin')->SetTemplate('SimpleJson');
    }
}